
package com.seekting.study;

import java.util.Vector;

public class ContainesTest {

    public static void main(String[] args) {
        Vector<Person> v = new Vector<ContainesTest.Person>();
        v.add(new Person("a"));
        Person person1 = new Person("a");
        System.out.println(v.contains(person1));
        System.out.println(person1.toString().equals(v.get(0).toString()));

    }

    /**
     * @author i
     */
    private static class Person {
        String name;

        public Person(String name) {
            super();
            this.name = name;
        }

        @Override
        public String toString() {
            return "Person [name=" + name + "]";
        }

        @Override
        public boolean equals(Object obj) {
            return obj != null && obj.toString().equals(this.toString());
        }

    }

}
